// component/baojie/baojie.js
var config = require("../../utils/config.js");
var network = require("../../utils/network.js");
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    cleaner:[],
    checked:''   //保洁师选择
  },
  /**
   * 组件的方法列表
   */
  ready(){
    this.getCleaner()
  },
  methods: {
    getCleaner:function(){
      network.request({
        url: config.host + 'api_cleaner/cleaner',
        method: "POST",
        success: (res) => {
          console.log("保洁员所有数据")
          console.log(res)
          if (res.data.code == 99) {
            this.setData({
              cleaner:res.data.data
            })
          } else {
            wx.showToast({
              title: res.data.msg,
            })
          }

        }
      })
    },
    chooseCleaner:function(e){
      let index = e.currentTarget.dataset.index
     this.setData({
       checked:index
     })
      this.triggerEvent("changeCleaner", this.data.cleaner[index])
      wx.setStorageSync("cleaner", { "data": this.data.cleaner[index]})
    }
  }
})
